package com.example.aircraftwar.codes.strategy;


import android.content.Context;

import com.example.aircraftwar.codes.aircraft.AbstractAircraft;
import com.example.aircraftwar.codes.bullet.BaseBullet;
import com.example.aircraftwar.codes.bullet.HeroBullet;

import java.util.LinkedList;
import java.util.List;

/**
 * 英雄机获取火力道具后一次散射三发子弹的射击方式
 *
 */

public class HeroDispersiveShoot implements ShootStrategy{
    private int shootNum = 3;
    private int power = 30;
    private int direction = -1;

    @Override
    public List<BaseBullet> executeShootStrategy(Context context, AbstractAircraft abstractAircraft) {
        List<BaseBullet> res = new LinkedList<>();
        int x = abstractAircraft.getLocationX();
        int y = abstractAircraft.getLocationY();
        int[] speedX = {-3, 0, 3};
        int speedY = abstractAircraft.getSpeedY() + direction*10;
        BaseBullet baseBullet;
        for(int i=0; i<shootNum; i++){
            // 子弹发射位置相对飞机位置向前偏移
            // 多个子弹横向分散
            baseBullet = new HeroBullet(context, x + (i * 2 - shootNum + 1) * 10, y, speedX[i], speedY, power);
            res.add(baseBullet);
        }
        return res;
    }

}
